<%@page import="java.util.Arrays"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">

    <title>首页</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link href="houtai/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="houtai/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">

    <!-- Morris -->
    <link href="houtai/css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">

    <!-- Gritter -->
    <link href="houtai/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">

    <link href="houtai/css/animate.css" rel="stylesheet">
    <link href="houtai/css/style.css?v=2.2.0" rel="stylesheet">
    <style type="text/css">
        #first{
            border-left: none;
        }
        .hiddenTD{
          display: none;
        }
       .form-group span{
         color: red;
        }
        .backTop{
         background-color: blue;
        }
    </style>
    <script>
        <c:if test="${sessionUsername==null}">
        window.location.href = "login.jsp";
        </c:if>
    </script>
</head>
<body>
 
    <div id="wrapper">
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element"> <span>
                            <img alt="image" class="img-circle" src="houtai/img/profile_small.jpg" />
                             </span>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="index.html#">
                                <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">${sessionUsername}</strong>
                             </span>  <span class="text-muted text-xs block" >${sessionTitle}<b class="caret"></b></span> </span>
                            </a>
                            <ul class="dropdown-menu animated fadeInRight m-t-xs">
                                <li class="divider"></li>
                                <li><a href="remove">安全退出</a>
                                </li>
                            </ul>
                        </div>
                        <div class="logo-element">
                            ${sessionUsername}
                        </div>

                    </li>
                    <li class="active" id="first">
                        <a href="index.do" style="border-left: 0px"><i class="fa fa-desktop"></i>主页 </a>
                    </li>
                    <li>
                        <a href="#"><i class="fa fa fa-globe"></i> <span class="nav-label">文章管理</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="getArticleList.do">文章列表</a>
                            </li>
                            <li><a href="getClassifyList.do">文章分类列表</a>
                            </li>
                        </ul>
                    </li>

                    <li>
                        <a href="#"><i class="fa fa fa-globe"></i> <span class="nav-label">订单管理</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="getOrders">订单列表</a>
                            </li>
                            <li><a href="getDetails">流水列表</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#"><i class="fa fa fa-globe"></i> <span class="nav-label">项目管理</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="getProjectList">项目列表</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#"><i class="fa fa fa-globe"></i> <span class="nav-label">车辆类型管理</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="getTypesList">车辆类型列表</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#"><i class="fa fa-flask"></i> <span class="nav-label">管理员设置</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="getMembersList.do">管理员列表</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a href="#"><i class="fa fa-flask"></i> <span class="nav-label">系统管理</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li><a href="authGroupList.do">角色管理</a>
                            </li>
                            <li><a href="modulesList.do">模块管理</a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>

        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top"   style="margin-bottom: 0">
                    <div class="navbar-header">
                        <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                        <form   class="navbar-form-custom" method="post" action="search_results.html">
                            <div class="form-group">
                                <input type="text" placeholder="请输入您需要查找的内容 …" class="form-control" name="top-search" id="top-search">
                            </div>
                        </form>
                    </div>
                    <ul class="nav navbar-top-links navbar-right">
                        <li>
                            <span class="m-r-sm text-muted welcome-message"><a href="index.html" title="返回首页"><i class="fa fa-home"></i></a>安全隐患管理系统欢迎您</span>
                        </li>

                        <li>
                            <a href="remove">
                                <i class="fa fa-sign-out"></i> 退出
                            </a>
                        </li>
                    </ul>

                </nav>
            </div> 
 
<!-----------------------------------------------------产品列表------------------------------------------------------------------>
    <div class="right"  id="mainFrame">
		<div class="right_cont">
			<ul class="breadcrumb">
			    <li> 当前位置：</li>
				<li> <a href="index.jsp">首页</a> </li>
				<li><a href="authGroupList.do">角色管理列表</a></li>
				<li>权限列表</li>
			</ul>
			<%
			  String rules =request.getParameter("rules");
			  String[] str = rules.split(",");
			  List list = new ArrayList();
			  list=Arrays.asList(str);
			  request.setAttribute("list", list);		
			%>

            <strong>权限选择</strong><br /><br />
			    <c:forEach items="${modules}" var="m">
			        <div class="backTop">${m.moduleName}</div><br>
			            <c:forEach items="${m.authRules}" var="z">
                            <c:choose>
                                <c:when test="${fn:contains(list, z.id)}">
                                   <label><input name="id" type="checkbox" value="${z.id}" checked="checked"/>${z.title} </label> &nbsp;&nbsp;&nbsp;
                                  </c:when>
                                  <c:otherwise>
                                      <label><input name="id" type="checkbox" value="${z.id}" />${z.title} </label> &nbsp;&nbsp;&nbsp;
                                  </c:otherwise>
                            </c:choose>
                        </c:forEach>
                </c:forEach><br>
            <input type="button" id="btn" value="提交">
            <input type="hidden" id="newID" value="${id}">
		</div>
	</div>
</div>
</div>
  
    <!-- Mainly scripts -->
    <script src="houtai/js/jquery-2.1.1.min.js"></script>
    <script src="houtai/js/bootstrap.min.js?v=3.4.0"></script>
    <script src="houtai/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="houtai/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
 
    <!-- Custom and plugin javascript -->
    <script src="houtai/js/hplus.js?v=2.2.0"></script>
    <script src="houtai/js/plugins/pace/pace.min.js"></script>

      <script type="text/javascript">
      $("document").ready(function(){  
      var newID = $('#newID').val();
      $("#btn").click(function(){//输出选中的值  
      var str=""; 
      $("input:checkbox[name='id']:checked").each(function(){ 
       str+=$(this).val()+",";    
       }); 
       str =str.substring(0,str.length-1);
       window.location.href="setAuthRule.do?id="+newID+"&rules="+str;
      });  
      });
        
    </script>
</body>

</html>